#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QPushButton *button = new QPushButton(this);
    button->setGeometry(300, 100, 100, 100); // x, y, w, h
    button->setText("按钮");

    // lamda函数定义槽函数
    connect(button, &QPushButton::clicked, this, [this](){
        setWindowTitle("jiuqi");
        ui->pushButton->setEnabled(!ui->pushButton->isEnabled());
    });

    // button->setEnabled(false);  // 禁用控件
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    qDebug() << "你好";
}
